import CONSTANT from '@/common/constants.js'
import http from '@/common/http.js'
import Tab from 'vux/src/components/tab/tab'
import TabItem from 'vux/src/components/tab/tab-item'
export default {
  name: 'togetherDonate',
  components: {
    Tab,
    TabItem
  },
  data () {
    return {
      event_id: '',
      personalArr: [],
      termArr: [],
      companyArr: [],
      tolist: [],
      messageText: ''
    }
  },
  mounted () {
    this.event_id = this.$route.query.event_id;
    http.post(CONSTANT.TOGETHER_LIST, {event_id: this.event_id}, (res) => {
      console.log(res)
      for (var i = 0; i < res.obj.length; i++){
        if (res.obj[i].style == 'personal' || res.obj[i].style == '') {
          this.personalArr.push(res.obj[i])
        } else if (res.obj[i].style == 'group') {
          this.termArr.push(res.obj[i])
        } else if (res.obj[i].style == 'company'){
          this.companyArr.push(res.obj[i])
        } else {
          this.personalArr.push(res.obj[i])
        }
      }
      this.tolist = this.personalArr
    })

  },
  methods: {
    witchShow (e) {
      console.log(e)
      if (e == 'geren') {
        this.tolist = this.personalArr
        this.messageText = '暂无个人一起捐'
      } else if (e == 'tuanti') {
        this.tolist = this.termArr
        this.messageText = '暂无团体一起捐'
      } else if (e == 'qiye') {
        this.tolist = this.companyArr
        this.messageText = '暂无企业一起捐'
      }
    },

    goTogetherDonate(id) {
      this.$router.push({path: '/homedonation', query: {together_id: id}})
    },
    // changeIcon () {
    //   if (!this.icon || this.icon === 'success') {
    //     this.icon = 'warn'
    //     return
    //   }
    //   if (this.icon === 'warn') {
    //     this.icon = 'info'
    //     return
    //   }
    //   if (this.icon === 'info') {
    //     this.icon = 'waiting'
    //     return
    //   }
    //   if (this.icon === 'waiting') {
    //     this.icon = 'success'
    //   }
    // },
    comeback () {
      // 返回上一页
      window.history.go(-1)
    },

  }
}
